/*
 * $Id: oam.h,v 1.52.2.2 Broadcom SDK $
 * 
 * $Copyright: Copyright 2011 Broadcom Corporation.
 * This program is the proprietary software of Broadcom Corporation
 * and/or its licensors, and may only be used, duplicated, modified
 * or distributed pursuant to the terms and conditions of a separate,
 * written license agreement executed between you and Broadcom
 * (an "Authorized License").  Except as set forth in an Authorized
 * License, Broadcom grants no license (express or implied), right
 * to use, or waiver of any kind with respect to the Software, and
 * Broadcom expressly reserves all rights in and to the Software
 * and all intellectual property rights therein.  IF YOU HAVE
 * NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS SOFTWARE
 * IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE
 * ALL USE OF THE SOFTWARE.  
 *  
 * Except as expressly set forth in the Authorized License,
 *  
 * 1.     This program, including its structure, sequence and organization,
 * constitutes the valuable trade secrets of Broadcom, and you shall use
 * all reasonable efforts to protect the confidentiality thereof,
 * and to use this information only in connection with your use of
 * Broadcom integrated circuit products.
 *  
 * 2.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS
 * PROVIDED "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES,
 * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY,
 * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE.  BROADCOM SPECIFICALLY
 * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
 * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES,
 * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
 * CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING
 * OUT OF USE OR PERFORMANCE OF THE SOFTWARE.
 * 
 * 3.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL
 * BROADCOM OR ITS LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL,
 * INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY DAMAGES WHATSOEVER
 * ARISING OUT OF OR IN ANY WAY RELATING TO YOUR USE OF OR INABILITY
 * TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF
 * THE AMOUNT ACTUALLY PAID FOR THE SOFTWARE ITSELF OR USD 1.00,
 * WHICHEVER IS GREATER. THESE LIMITATIONS SHALL APPLY NOTWITHSTANDING
 * ANY FAILURE OF ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.$
 * 
 * DO NOT EDIT THIS FILE!
 * This file is auto-generated.
 * Edits to this file will be lost when it is regenerated.
 */

#ifndef __BCM_OAM_H__
#define __BCM_OAM_H__

#include <bcm/mpls.h>

/* Miscellaneous OAM defines */
#define BCM_OAM_GROUP_NAME_LENGTH   48         /* Group name length in bytes */
#define BCM_OAM_GROUP_INVALID       -1         /* Invalid OAM group ID */
#define BCM_OAM_ENDPOINT_INVALID    -1         /* Invalid OAM endpoint ID */
#define BCM_OAM_INTPRI_MAX          16         /* Internal priority max value */

/* OAM group flags */
#define BCM_OAM_GROUP_REPLACE               0x01       /* Replace an existing
                                                          OAM group */
#define BCM_OAM_GROUP_WITH_ID               0x02       /* Use the specified
                                                          group ID */
#define BCM_OAM_GROUP_REMOTE_DEFECT_TX      0x04       /* Set the remote defect
                                                          indicator in outgoing
                                                          CCMs for this group */
#define BCM_OAM_GROUP_COPY_ERRORS_TO_CPU    0x08       /* Copy mismatched MAID
                                                          packets to CPU */
#define BCM_OAM_GROUP_COPY_TO_CPU           0x10       /* Copy the received CCM
                                                          packet to the CPU */

/* OAM group fault flags */
#define BCM_OAM_GROUP_FAULT_REMOTE      0x01       /* A remote defect indicator
                                                      is set in this group */
#define BCM_OAM_GROUP_FAULT_CCM_TIMEOUT 0x02       /* A CCM timeout has occurred
                                                      in this group */
#define BCM_OAM_GROUP_FAULT_CCM_ERROR   0x04       /* A CCM error has occurred
                                                      in this group */
#define BCM_OAM_GROUP_FAULT_CCM_XCON    0x08       /* A CCM xcon has occurred in
                                                      this group */

/* OAM endpoint flags */
#define BCM_OAM_ENDPOINT_REPLACE            0x0001     /* Replace an existing
                                                          OAM endpoint */
#define BCM_OAM_ENDPOINT_WITH_ID            0x0002     /* Use the specified
                                                          endpoint ID */
#define BCM_OAM_ENDPOINT_REMOTE             0x0004     /* Specifies that this is
                                                          a remote endpoint */
#define BCM_OAM_ENDPOINT_UP_FACING          0x0008     /* Specifies that this
                                                          endpoint faces the
                                                          switching logic */
#define BCM_OAM_ENDPOINT_CCM_RX             0x0010     /* Enables CCM reception.
                                                           This is only valid
                                                          for local endpoints. */
#define BCM_OAM_ENDPOINT_LOOPBACK           0x0020     /* Enables loopback
                                                          response.  This is
                                                          only valid for local
                                                          endpoints. */
#define BCM_OAM_ENDPOINT_DELAY_MEASUREMENT  0x0040     /* Enables reception and
                                                          timestamping of delay
                                                          measurement messages. 
                                                          This is only valid for
                                                          local endpoints. */
#define BCM_OAM_ENDPOINT_LINKTRACE          0x0080     /* Enables reception of
                                                          linktrace messages. 
                                                          This is only valid for
                                                          local endpoints. */
#define BCM_OAM_ENDPOINT_PORT_STATE_TX      0x0100     /* Enables the
                                                          transmission of port
                                                          state in outgoing
                                                          CCMs.  This is only
                                                          valid for local
                                                          endpoints. */
#define BCM_OAM_ENDPOINT_INTERFACE_STATE_TX 0x0200     /* Enables the
                                                          transmission of
                                                          interface state in
                                                          outgoing CCMs.  This
                                                          is only valid for
                                                          local endpoints. */
#define BCM_OAM_ENDPOINT_LOSS_MEASUREMENT   0x0400     /* Enables the processing
                                                          of loss measurement
                                                          messages.  This is
                                                          only valid for local
                                                          endpoints. */
#define BCM_OAM_ENDPOINT_INTERMEDIATE       0x0800     /* Configures this as a
                                                          MIP. */
#define BCM_OAM_ENDPOINT_PBB_TE             0x1000     /* Specifies that this is
                                                          a PBB-TE endpoint. */
#define BCM_OAM_ENDPOINT_CCM_COPYTOCPU      0x2000     /* Copy received CCM to
                                                          CPU. This is only
                                                          valid for local
                                                          endpoints. */
#define BCM_OAM_ENDPOINT_CCM_DROP           0x4000     /* Drop received CCM.
                                                          This is only valid for
                                                          local endpoints. */
#define BCM_OAM_ENDPOINT_DM_COPYTOCPU       0x8000     /* Copy received delay
                                                          measurement messages
                                                          to CPU. This is only
                                                          valid for local
                                                          endpoints. */
#define BCM_OAM_ENDPOINT_DM_DROP            0x10000    /* Drop received delay
                                                          measurement messages.
                                                          This is only valid for
                                                          local endpoints. */
#define BCM_OAM_ENDPOINT_LB_COPYTOCPU       0x20000    /* Copy received loopback
                                                          messages to CPU. This
                                                          is only valid for
                                                          local endpoints. */
#define BCM_OAM_ENDPOINT_LB_DROP            0x40000    /* Drop received loopback
                                                          messages. This is only
                                                          valid for local
                                                          endpoints. */
#define BCM_OAM_ENDPOINT_LT_COPYTOCPU       0x80000    /* Copy received loopback
                                                          messages to CPU. This
                                                          is only valid for
                                                          local endpoints. */
#define BCM_OAM_ENDPOINT_LT_DROP            0x100000   /* Drop received loopback
                                                          messages. This is only
                                                          valid for local
                                                          endpoints. */
#define BCM_OAM_ENDPOINT_USE_QOS_MAP        0x200000   /* Use QoS map profile
                                                          specified on endpoint */
#define BCM_OAM_ENDPOINT_MATCH_INNER_VLAN   0x400000   /* Selection of up MIP on
                                                          CEP (C-comp) rather
                                                          than on PEP (S-comp). */
#define BCM_OAM_ENDPOINT_REMOTE_DEFECT_TX   0x800000   /* Set the remote defect
                                                          indicator in outgoing
                                                          CCMs for this
                                                          endpoint. */
#define BCM_OAM_ENDPOINT_CCM_COPYFIRSTTOCPU 0x1000000  /* Copy only the first
                                                          (next) received CCM to
                                                          CPU. This is only
                                                          valid for local
                                                          endpoints. */

/* OAM opcode flags */
#define BCM_OAM_OPCODE_CCM_IN_HW            0x0001     /* Process CCMs in
                                                          Hardware */
#define BCM_OAM_OPCODE_CCM_COPY_TO_CPU      0x0002     /* Copy CCMs to CPU */
#define BCM_OAM_OPCODE_CCM_DROP             0x0004     /* Drop CCMs */
#define BCM_OAM_OPCODE_LBM_IN_HW            0x0008     /* Process Loopback
                                                          Messages in Hardware */
#define BCM_OAM_OPCODE_LBM_UC_COPY_TO_CPU   0x0010     /* Copy Unicast Loopback
                                                          Messages to CPU */
#define BCM_OAM_OPCODE_LBM_UC_DROP          0x0020     /* Drop Unicast Loopback
                                                          Messages */
#define BCM_OAM_OPCODE_LBM_MC_COPY_TO_CPU   0x0040     /* Copy Multicast
                                                          Loopback Messages to
                                                          CPU */
#define BCM_OAM_OPCODE_LBM_MC_DROP          0x0080     /* Drop Multicast
                                                          Loopback Messages */
#define BCM_OAM_OPCODE_LBR_COPY_TO_CPU      0x0100     /* Copy Loopback Reply to
                                                          CPU */
#define BCM_OAM_OPCODE_LBR_DROP             0x0200     /* Drop Loopback Reply */
#define BCM_OAM_OPCODE_LTM_COPY_TO_CPU      0x0400     /* Copy Linktrace
                                                          Messages to CPU */
#define BCM_OAM_OPCODE_LTM_DROP             0x0800     /* Drop Linktrace
                                                          Messages */
#define BCM_OAM_OPCODE_LTR_COPY_TO_CPU      0x1000     /* Copy Linktrace Reply
                                                          to CPU */
#define BCM_OAM_OPCODE_LTR_DROP             0x2000     /* Drop Linktrace Reply */
#define BCM_OAM_OPCODE_LMEP_PKT_FWD         0x4000     /* Forward CCMs to remote
                                                          device */
#define BCM_OAM_OPCODE_OTHER_COPY_TO_CPU    0x8000     /* Copy other OAM opcode
                                                          to CPU */
#define BCM_OAM_OPCODE_OTHER_DROP           0x10000    /* Drop other OAM opcode
                                                          to CPU */

/* OAM endpoint fault flags */
#define BCM_OAM_ENDPOINT_FAULT_CCM_TIMEOUT  0x01       /* Indicates a CCM
                                                          timeout.  This is only
                                                          valid for remote
                                                          endpoints and is
                                                          read-only. */
#define BCM_OAM_ENDPOINT_FAULT_REMOTE       0x02       /* Indicates that a
                                                          remote defect was
                                                          indicated in the last
                                                          CCM received from this
                                                          endpoint.  This is
                                                          only valid for remote
                                                          endpoints and is
                                                          read-only. */
#define BCM_OAM_ENDPOINT_FAULT_PORT_DOWN    0x04       /* Indicates that the
                                                          port on which the
                                                          endpoint resides is
                                                          down.  This is valid
                                                          for both local and
                                                          remote endpoints but
                                                          is read-only for
                                                          remote endpoints. */
#define BCM_OAM_ENDPOINT_FAULT_INTERFACE_DOWN 0x08       /* Indicates that the
                                                          interface on which teh
                                                          endpoint resides is
                                                          down.  This is valid
                                                          for both local and
                                                          remote endpoints but
                                                          is read-only for
                                                          remote endpoints. */

/* Constants for CCM periods defined by 802.1ag */
#define BCM_OAM_ENDPOINT_CCM_PERIOD_DISABLED 0          
#define BCM_OAM_ENDPOINT_CCM_PERIOD_3MS     3          
#define BCM_OAM_ENDPOINT_CCM_PERIOD_10MS    10         
#define BCM_OAM_ENDPOINT_CCM_PERIOD_100MS   100        
#define BCM_OAM_ENDPOINT_CCM_PERIOD_1S      1000       
#define BCM_OAM_ENDPOINT_CCM_PERIOD_10S     10000      
#define BCM_OAM_ENDPOINT_CCM_PERIOD_1M      60000      
#define BCM_OAM_ENDPOINT_CCM_PERIOD_10M     600000     

/* OAM loss flags */
#define BCM_OAM_LOSS_TX_ENABLE              0x0001     /* Enable Loss Packet
                                                          Transmission */
#define BCM_OAM_LOSS_SINGLE_ENDED           0x0002     /* Single Ended Mode */
#define BCM_OAM_LOSS_FIRST_RX_COPY_TO_CPU   0x0004     /* Copy First received
                                                          Loss Measurement
                                                          Packet to CPU */
#define BCM_OAM_LOSS_ALL_RX_COPY_TO_CPU     0x0008     /* Copy all received Loss
                                                          Measurement Packet to
                                                          CPU */

/* OAM delay flags */
#define BCM_OAM_DELAY_TX_ENABLE             0x0001     /* Enable Delay Packet
                                                          Transmission */
#define BCM_OAM_DELAY_ONE_WAY               0x0002     /* One Way Mode */
#define BCM_OAM_DELAY_FIRST_RX_COPY_TO_CPU  0x0004     /* Copy First received
                                                          Delay Measurement
                                                          Packet to CPU */
#define BCM_OAM_DELAY_ALL_RX_COPY_TO_CPU    0x0008     /* Copy all received
                                                          Delay Measurement
                                                          Packet to CPU */

/* OAM PSC flags */
#define BCM_OAM_PSC_TX_BURST                0x0001     /* Trigger PSC Burst
                                                          Transmission */
#define BCM_OAM_PSC_TX_SLOW                 0x0002     /* Enable PSC slow-rate
                                                          Transmission */
#define BCM_OAM_PSC_REVERTIVE               0x0004     /* Enable Revertive mode */
#define BCM_OAM_PSC_FIRST_RX_COPY_TO_CPU    0x0008     /* Copy First received
                                                          PSC Measurement Packet
                                                          to CPU */
#define BCM_OAM_PSC_ALL_RX_COPY_TO_CPU      0x0010     /* Copy all received PSC
                                                          Measurement Packet to
                                                          CPU */

/* OAM event types */
typedef enum bcm_oam_endpoint_type_e {
    bcmOAMEndpointTypeEthernet, 
    bcmOAMEndpointTypeMPLSPerformance,  /* MPLS performance monitoring endpoint */
    bcmOAMEndpointTypeBFDVccv,          /* Psuedowire Virtual Circuit
                                           Connectivity Verification BFD */
    bcmOAMEndpointTypeBFDVccvCcCv,      /* Psuedowire Virtual Circuit
                                           Connectivity Verification BFD for
                                           MPLS-TP proactive CC&CV */
    bcmOAMEndpointTypeBFDMPLS,          /* BFD for MPLS LSP */
    bcmOAMEndpointTypeBFDMPLSCcCv,      /* BFD for MPLS-TP proactive CC&CV */
    bcmOAMEndpointTypePSC,              /* Protection coordination state
                                           protocol endpoint */
    bcmOAMEndpointTypeCount 
} bcm_oam_endpoint_type_t;

/* OAM event types */
typedef enum bcm_oam_event_type_e {
    bcmOAMEventEndpointPortDown, 
    bcmOAMEventEndpointPortUp, 
    bcmOAMEventEndpointInterfaceDown, 
    bcmOAMEventEndpointInterfaceUp, 
    bcmOAMEventEndpointInterfaceTestingToUp, 
    bcmOAMEventEndpointInterfaceUnknownToUp, 
    bcmOAMEventEndpointInterfaceDormantToUp, 
    bcmOAMEventEndpointInterfaceNotPresentToUp, 
    bcmOAMEventEndpointInterfaceLLDownToUp, 
    bcmOAMEventEndpointInterfaceTesting, 
    bcmOAMEventEndpointInterfaceUnkonwn, 
    bcmOAMEventEndpointInterfaceDormant, 
    bcmOAMEventEndpointInterfaceNotPresent, 
    bcmOAMEventEndpointInterfaceLLDown, 
    bcmOAMEventGroupCCMxcon, 
    bcmOAMEventGroupCCMError, 
    bcmOAMEventGroupRemote, 
    bcmOAMEventGroupCCMTimeout, 
    bcmOAMEventBFDTimeout, 
    bcmOAMEventCount 
} bcm_oam_event_type_t;

/* BFD State */
typedef enum bcm_oam_bfd_state_e {
    bcmOAMBFDStateAdminDown, 
    bcmOAMBFDStateDown, 
    bcmOAMBFDStateInit, 
    bcmOAMBFDStateUp, 
    bcmOAMBFDStateCount 
} bcm_oam_bfd_state_t;

/* BFD diagnostic code */
typedef enum bcm_oam_bfd_diag_code_e {
    bcmOAMBFDDiagCodeNone, 
    bcmOAMBFDDiagCodeCtrlDetectTimeExpired, 
    bcmOAMBFDDiagCodeEchoFailed, 
    bcmOAMBFDDiagCodeNeighbourSignalledDown, 
    bcmOAMBFDDiagCodeForwardingPlaneReset, 
    bcmOAMBFDDiagCodePathDown, 
    bcmOAMBFDDiagCodeConcatPathDown, 
    bcmOAMBFDDiagCodeAdminDown, 
    bcmOAMBFDDiagCodeRevConcatPathDown, 
    bcmOAMBFDDiagCodeCount 
} bcm_oam_bfd_diag_code_t;

/* BFD Authentication Type */
typedef enum bcm_oam_bfd_auth_type_e {
    bcmOAMBFDAuthTypeResv, 
    bcmOAMBFDAuthTypeSimplePassword, 
    bcmOAMBFDAuthTypeKeyedMD5, 
    bcmOAMBFDAuthTypeMeticulousKeyedMD5, 
    bcmOAMBFDAuthTypeKeyedSHA1, 
    bcmOAMBFDAuthTypeMeticulousKeyedSHA1, 
    bcmOAMBFDAuthTypeCount 
} bcm_oam_bfd_auth_type_t;

/* OAM Group Fault Alarm Defects and Priorities */
typedef enum bcm_oam_group_fault_alarm_defect_priority_e {
    bcmOAMGroupFaultAlarmPriorityDefectsAll, /* Generate fault alarm for all defects */
    bcmOAMGroupFaultAlarmPriorityDefectRDICCM, /* Generate fault alarm when CCM
                                           received by this Maintenance Endpoint
                                           from some remote Maintenance Endpoint
                                           contained RDI bit */
    bcmOAMGroupFaultAlarmPriorityDefectMACStatus, /* Generate fault alarm when the last
                                           CCM received by this MEP from some
                                           remote MEP indicated that the
                                           Transmitting Maintenance Endpoint's
                                           associated MAC is reporting an error
                                           status */
    bcmOAMGroupFaultAlarmPriorityDefectRemoteCCM, /* Generate fault alarm when Maintenance
                                           Endpoint is not receiving CCMs from
                                           some other Maintenance Endpoint in
                                           its configured list */
    bcmOAMGroupFaultAlarmPriorityDefectErrorCCM, /* Generate fault alarm when Maintenance
                                           Endpoint is receiving Invalid CCMs */
    bcmOAMGroupFaultAlarmPriorityDefectXconCCM, /* Generate fault alarm when Maintenance
                                           Endpoint is receiving CCMs that could
                                           be from some other MA */
    bcmOAMGroupFaultAlarmPriorityDefectsNone, /* No Defects are reported */
    bcmOAMGroupFaultAlarmPriorityCount 
} bcm_oam_group_fault_alarm_defect_priority_t;

/* BFD flags */
#define BCM_OAM_BFD_UNIDIRECTIONAL          0x0800     /* Create a Unidirection
                                                          BFD endpoint */
#define BCM_OAM_BFD_CV_TYPE_RAW             0x0400     /* Raw BFD Without IP/UDP
                                                          Header */
#define BCM_OAM_BFD_CV_TYPE_IP              0x0200     /* BFD With IP/UDP Header */
#define BCM_OAM_BFD_TTSI_TLV                0x0100     /* BFD with Trail
                                                          Termination Source
                                                          Identifier (TTSI) TLV
                                                          Object */
#define BCM_OAM_BFD_DA_TLV                  0x0080     /* BFD with DA TLV object */
#define BCM_OAM_BFD_SA_TLV                  0x0040     /* BFD with SA TLV object */
#define BCM_OAM_BFD_POLL                    0x0020     /* BFD Poll flag */
#define BCM_OAM_BFD_FINAL                   0x0010     /* BFD Final flag */
#define BCM_OAM_BFD_CONTROL_INDEPENDENT     0x0008     /* BFD Control Plane
                                                          Independent flag */
#define BCM_OAM_BFD_OAM_BFD_AUTHENTICATE    0x0004     /* BFD Authentication
                                                          flag */
#define BCM_OAM_BFD_DEMAND_MODE             0x0002     /* BFD Demand mode */
#define BCM_OAM_BFD_MULTIPOINT              0x0001     /* Multipoint BFD */

/* OAM event callback flags */
#define BCM_OAM_EVENT_FLAGS_MULTIPLE    0x01       /* Indicates that more than
                                                      one event of the given
                                                      type has occurred. */

typedef struct bcm_oam_event_types_s {
    SHR_BITDCL w[_SHR_BITDCLSIZE(bcmOAMEventCount)]; 
} bcm_oam_event_types_t;

#define BCM_OAM_EVENT_TYPE_SET(_event_types, _event_type)  SHR_BITSET(_event_types.w, _event_type) 

#define BCM_OAM_EVENT_TYPE_GET(_event_types, _event_type)  SHR_BITGET(_event_types.w, _event_type) 

#define BCM_OAM_EVENT_TYPE_CLEAR(_event_types, _event_type)  SHR_BITCLR(_event_types.w, _event_type) 

#define BCM_OAM_EVENT_TYPE_SET_ALL(_event_types)  SHR_BITSET_RANGE(_event_types.w, 0, bcmOAMEventCount) 

#define BCM_OAM_EVENT_TYPE_CLEAR_ALL(_event_types)  SHR_BITCLR_RANGE(_event_types.w, 0, bcmOAMEventCount) 

/* OAM group ID type */
typedef int bcm_oam_group_t;

/* 
 * OAM group object.  This is equivalent to an 802.1ag Maintenance
 * Association (MA).
 */
typedef struct bcm_oam_group_info_s {
    uint32 flags; 
    bcm_oam_group_t id; 
    uint8 name[BCM_OAM_GROUP_NAME_LENGTH]; /* This is equivalent to the Maintenance
                                           Association ID (MAID) in 802.1ag. 
                                           Note that this is not a
                                           null-terminated string but an array
                                           of bytes.  To avoid memory
                                           corruption, do not use string copy to
                                           populate this field. */
    uint32 faults;                      /* Fault flags */
    uint32 persistent_faults;           /* Persistent fault flags */
    uint32 clear_persistent_faults;     /* Persistent fault flags to clear on a
                                           'get' */
    bcm_oam_group_fault_alarm_defect_priority_t lowest_alarm_priority; /* Generate fault alarm for this
                                           maintenance endpoint when defects of
                                           greater than or equal to this
                                           priority value are detected on this
                                           maintenance endpoint */
} bcm_oam_group_info_t;

/* OAM endpoint ID type */
typedef int bcm_oam_endpoint_t;

/* 
 * OAM endpoint object.  This is equivalent to an 802.1ag Maintenance
 * Endpoint (MEP).
 */
typedef struct bcm_oam_endpoint_info_s {
    uint32 flags; 
    uint32 opcode_flags;                /* OAM opcode flags */
    bcm_oam_endpoint_t id; 
    bcm_oam_endpoint_type_t type; 
    bcm_oam_group_t group;              /* The ID of the group to which this
                                           endpoint belongs */
    uint16 name;                        /* A unique identifier of the endpoint
                                           within the group.  This is equivalent
                                           to the MEPID in 802.1ag. */
    bcm_oam_endpoint_t local_id;        /* Used by remote endpoints only. */
    int level;                          /* This is equivalent to the Maintenance
                                           Domain Level (MDL) in 802.1ag. */
    int ccm_period;                     /* For local endpoints, this is the CCM
                                           transmission period in ms.  For
                                           remote endpoints, this is the period
                                           on which CCM timeout is based. */
    bcm_vlan_t vlan;                    /* The VLAN associated with this
                                           endpoint */
    bcm_gport_t gport;                  /* The gport associated with this
                                           endpoint */
    int trunk_index;                    /* The trunk port index for this
                                           endpoint */
    bcm_if_t intf_id;                   /* Interface Identifier */
    bcm_mpls_label_t mpls_label;        /* The MPLS label associated with
                                           packets received from the Peer
                                           Endpoint */
    bcm_mpls_egress_label_t egress_label; /* The MPLS outgoing label information
                                           for the Local Endpoint */
    bcm_mac_t dst_mac_address;          /* The destination MAC address
                                           associated with this endpoint */
    bcm_mac_t src_mac_address;          /* The source MAC address associated
                                           with this endpoint */
    uint8 pkt_pri;                      /* Egress marking for outgoing CCMs */
    bcm_cos_t int_pri;                  /* Egress queuing for outgoing CCMs */
    uint8 cpu_qid;                      /* CPU queue for CCMs */
    uint8 pri_map[BCM_OAM_INTPRI_MAX];  /* Priority mapping for LM counter table */
    uint32 faults;                      /* Fault flags */
    uint32 persistent_faults;           /* Persistent fault flags */
    uint32 clear_persistent_faults;     /* Persistent fault flags to clear on a
                                           'get' */
    int ing_map;                        /* Ingress QoS map profile */
    int egr_map;                        /* Egress QoS map profile */
    uint8 bfd_version;                  /* BFD Version */
    uint32 bfd_flags;                   /* BFD flag */
    bcm_oam_bfd_state_t bfd_state;      /* BFD state */
    bcm_oam_bfd_diag_code_t diag_code;  /* BFD Diagnostic code */
    int min_tx_interval;                /* BFD minimum transmit interval in
                                           microseconds */
    uint32 detect_mult;                 /* BFD timer Detection Multiplier */
    int min_rx_interval;                /* BFD minimum receive interval in
                                           microseconds */
    int min_echo_interval;              /* BFD echo rx interval in microseconds */
    uint32 my_discriminator_id;         /* BFD endpoint discriminator id */
    bcm_oam_bfd_auth_type_t auth_type;  /* BFD authentication type */
    uint8 auth_len;                     /* BFD authentication length */
    bcm_ip_t source_ip;                 /* BFD source IP address */
    bcm_ip_t dest_ip;                   /* BFD destination IP address */
    uint16 udp_src_port;                /* BFD source UDP port */
    uint16 udp_dest_port;               /* BFD destination UDP port */
} bcm_oam_endpoint_info_t;

/* OAM loss object. */
typedef struct bcm_oam_loss_s {
    uint32 flags; 
    bcm_oam_endpoint_t id;          /* Endpoint ID of Local MEP. */
    bcm_oam_endpoint_t remote_id;   /* Endpoint ID of Remote MEP. */
    int period;                     /* Frequency of loss tx period in
                                       milliseconds. */
    int loss_threshold;             /* Loss ratio (expressed in 100th of
                                       percent) which if exceeded will declare
                                       the period degraded with a Loss
                                       Measurement packet exception.  A value of
                                       -1 for Loss Measurement exception on all
                                       received packets. */
    int loss_nearend;               /* Nearend loss (expressed in 100th of
                                       percent). A value os -1 if not available. */
    int loss_farend;                /* Farend loss (expressed in 100th of
                                       percent). A value os -1 if not available. */
    uint32 tx_nearend;              /* Last local transmit frame count recorded
                                       at time of LMR */
    uint32 rx_nearend;              /* Last local receive frame count recorded
                                       at time of LMR */
    uint32 tx_farend;               /* Last peer transmit frame count recorded
                                       at time of LMR */
    uint32 rx_farend;               /* Last peer receive frame count recorded at
                                       time of LMR */
    uint8 pkt_pri_bitmap;           /* Bitmap of packet priorities which should
                                       be counted for LM.  A value of zero is
                                       the equivalent of all ones. */
    uint8 pkt_pri;                  /* Egress marking for outgoing LM messages */
    bcm_cos_t int_pri;              /* Egress queuing for outgoing LM messages */
} bcm_oam_loss_t;

/* OAM delay object. */
typedef struct bcm_oam_delay_s {
    uint32 flags; 
    bcm_oam_endpoint_t id;          /* Endpoint ID of Local MEP. */
    bcm_oam_endpoint_t remote_id;   /* Endpoint ID of Remote MEP. */
    int period;                     /* Frequency of delay tx period in
                                       milliseconds. */
    bcm_time_spec_t delay;          /* Last recorded delay to remote peer. */
    uint8 pkt_pri;                  /* Egress marking for outgoing DM messages */
    bcm_cos_t int_pri;              /* Egress queuing for outgoing DM messages */
} bcm_oam_delay_t;

/* OAM PSC object. */
typedef struct bcm_oam_psc_s {
    uint32 flags; 
    bcm_oam_endpoint_t id;          /* Endpoint ID of Local MEP. */
    bcm_oam_endpoint_t remote_id;   /* Endpoint ID of Remote MEP. */
    int version;                    /* Version number of message. */
    int request;                    /* Request field. */
    int pt;                         /* Protection type. */
    uint8 fpath;                    /* The path reporting failure. */
    uint8 path;                     /* The currently active path. */
    int burst_rate;                 /* Burst interval in ms (suggested 3 ms). */
    int slow_rate;                  /* Slow or normal interval in ms (suggested
                                       5000 ms). */
    int tlv_length;                 /* Length of optional TLV. */
    uint8 tlv;                      /* Optional TLV(s) of tlv_length. */
} bcm_oam_psc_t;

/* Callback function type for OAM group traversal */
typedef int (*bcm_oam_group_traverse_cb)(
    int unit, 
    bcm_oam_group_info_t *group_info, 
    void *user_data);

/* Callback function type for OAM endpoint traversal */
typedef int (*bcm_oam_endpoint_traverse_cb)(
    int unit, 
    bcm_oam_endpoint_info_t *endpoint_info, 
    void *user_data);

/* Callback function type for OAM event handling */
typedef int (*bcm_oam_event_cb)(
    int unit, 
    uint32 flags, 
    bcm_oam_event_type_t event_type, 
    bcm_oam_group_t group, 
    bcm_oam_endpoint_t endpoint, 
    void *user_data);

#ifndef BCM_HIDE_DISPATCHABLE

/* Initialize the OAM subsystem */
extern int bcm_oam_init(
    int unit);

/* Shut down the OAM subsystem */
extern int bcm_oam_detach(
    int unit);

#endif /* BCM_HIDE_DISPATCHABLE */

/* Initialize an OAM group info structure */
extern void bcm_oam_group_info_t_init(
    bcm_oam_group_info_t *group_info);

#ifndef BCM_HIDE_DISPATCHABLE

/* Create or replace an OAM group object */
extern int bcm_oam_group_create(
    int unit, 
    bcm_oam_group_info_t *group_info);

/* Get an OAM group object */
extern int bcm_oam_group_get(
    int unit, 
    bcm_oam_group_t group, 
    bcm_oam_group_info_t *group_info);

/* 
 * Destroy an OAM group object.  All OAM endpoints associated with the
 * group will also be destroyed.
 */
extern int bcm_oam_group_destroy(
    int unit, 
    bcm_oam_group_t group);

/* 
 * Destroy all OAM group objects.  All OAM endpoints will also be
 * destroyed.
 */
extern int bcm_oam_group_destroy_all(
    int unit);

/* 
 * Traverse the entire set of OAM groups, calling a specified callback
 * for each one
 */
extern int bcm_oam_group_traverse(
    int unit, 
    bcm_oam_group_traverse_cb cb, 
    void *user_data);

#endif /* BCM_HIDE_DISPATCHABLE */

/* Initialize an OAM endpoint info structure */
extern void bcm_oam_endpoint_info_t_init(
    bcm_oam_endpoint_info_t *endpoint_info);

#ifndef BCM_HIDE_DISPATCHABLE

/* Create or replace an OAM endpoint object */
extern int bcm_oam_endpoint_create(
    int unit, 
    bcm_oam_endpoint_info_t *endpoint_info);

/* Get an OAM endpoint object */
extern int bcm_oam_endpoint_get(
    int unit, 
    bcm_oam_endpoint_t endpoint, 
    bcm_oam_endpoint_info_t *endpoint_info);

/* Destroy an OAM endpoint object */
extern int bcm_oam_endpoint_destroy(
    int unit, 
    bcm_oam_endpoint_t endpoint);

/* Destroy all OAM endpoint objects associated with a given OAM group */
extern int bcm_oam_endpoint_destroy_all(
    int unit, 
    bcm_oam_group_t group);

/* 
 * Traverse the set of OAM endpoints associated with the specified group,
 * calling a specified callback for each one
 */
extern int bcm_oam_endpoint_traverse(
    int unit, 
    bcm_oam_group_t group, 
    bcm_oam_endpoint_traverse_cb cb, 
    void *user_data);

#endif /* BCM_HIDE_DISPATCHABLE */

/* Initialize an OAM loss structure */
extern void bcm_oam_loss_t_init(
    bcm_oam_loss_t *loss_ptr);

#ifndef BCM_HIDE_DISPATCHABLE

/* Add an OAM loss object */
extern int bcm_oam_loss_add(
    int unit, 
    bcm_oam_loss_t *loss_ptr);

/* Get an OAM loss object */
extern int bcm_oam_loss_get(
    int unit, 
    bcm_oam_loss_t *loss_ptr);

/* Delete an OAM loss object */
extern int bcm_oam_loss_delete(
    int unit, 
    bcm_oam_loss_t *loss_ptr);

#endif /* BCM_HIDE_DISPATCHABLE */

/* Initialize an OAM delay structure */
extern void bcm_oam_delay_t_init(
    bcm_oam_delay_t *delay_ptr);

#ifndef BCM_HIDE_DISPATCHABLE

/* Add an OAM delay object */
extern int bcm_oam_delay_add(
    int unit, 
    bcm_oam_delay_t *delay_ptr);

/* Get an OAM delay object */
extern int bcm_oam_delay_get(
    int unit, 
    bcm_oam_delay_t *delay_ptr);

/* Delete an OAM delay object */
extern int bcm_oam_delay_delete(
    int unit, 
    bcm_oam_delay_t *delay_ptr);

#endif /* BCM_HIDE_DISPATCHABLE */

/* Initialize an OAM PSC structure */
extern void bcm_oam_psc_t_init(
    bcm_oam_psc_t *psc_ptr);

#ifndef BCM_HIDE_DISPATCHABLE

/* Add an OAM PSC object */
extern int bcm_oam_psc_add(
    int unit, 
    bcm_oam_psc_t *psc_ptr);

/* Get an OAM PSC object */
extern int bcm_oam_psc_get(
    int unit, 
    bcm_oam_psc_t *psc_ptr);

/* Delete an OAM PSC object */
extern int bcm_oam_psc_delete(
    int unit, 
    bcm_oam_psc_t *psc_ptr);

/* Register a callback for handling OAM events */
extern int bcm_oam_event_register(
    int unit, 
    bcm_oam_event_types_t event_types, 
    bcm_oam_event_cb cb, 
    void *user_data);

/* Unregister a callback for handling OAM events */
extern int bcm_oam_event_unregister(
    int unit, 
    bcm_oam_event_types_t event_types, 
    bcm_oam_event_cb cb);

#endif /* BCM_HIDE_DISPATCHABLE */

#endif /* __BCM_OAM_H__ */
